<?php
/**
 * XmuSlh, web platform of Student Association Federation of Xiamen University
 * 
 * Rewritting one or some pages of StatusNet. 
 * To get the original version, please visit <http://status.net/>.
 * 
 * StatusNet, the distributed open-source microblogging tool
 * 
 * LICENCE: This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * Base action for 'editing' action.
 * 
 * '编辑,编辑数据'action的基类耶.
 * 
 * @author		ytukie <ytukie@gmail.com>
 * @version		0.1
 */

// XmuSlh only.
if ( !defined('XMUSLH')) { exit(1); }

// Requirements.
require_once INSTALLDIR . '/lib/slh_util.php';
require_once INSTALLDIR . '/lib/slh_action.php';


class EditAction extends Action
{
	/**
	 * Have we edited?
	 */
	var $edited = false;
	
	/**
	 * Has some instruction?
	 */
	var $instruction = null;
	
	/**
	 * Overrideing the showInnerContent().
	 */
	function showInnerContent()
	{
		$this->showGuidance();
		$this->element('hr');
		
		$this->showInstruction();
		$this->showForm();
		
		$this->element('hr');
	}
	
// Overrided ends //////////////////////////////////////////////////////////////
	/**
	 * Shows the guidance.
	 * Overriding.
	 */
	function showGuidance()
	{
		$this->element('h3', null, '编辑数据');
		
		$this->instruction('说明怎么编辑好了.');
		
		// If edited successfully, then?
		if ($this->edited) {
			$this->element('p', null, '编辑成功!');
			// Or show a nav.
		}
	}
	
	/**
	 * Shows the widgets like form, or etc.
	 * Overriding.
	 */
	function showForm()
	{
	}
	
	/**
	 * Try to edit the data into the database.
	 * Overriding.
	 */
	function tryEdit()
	{
	}
	
	/**
	 * Shows the instruction this page.
	 */
	function showInstruction()
	{
		if ($this->instruction) {
			$this->elementStart('div', array('class' => 'cls_div_instruction'));
			$this->instruction($this->instruction);
			$this->elementEnd('div');
		}
	}
	
	/**
	 * Shows the action with instruction.
	 */
	function showAction($instruction = null)
	{
		$this->instruction = $instruction;
		$this->showPage();
		// $this->instruction = null;
	}
}

?>